#size
res<-300
width<-500*res/72
height<-4/5*width

color<-c('gray80','gray45', 'gray15')
space<-c(0,2)#spaces between pairs of bars
border<-T
lwd_border<-0.5

#grid
lwd_grid<-0.5
color_grid<-"black"

#Data

LC3<-c(2.55,2)
LC5<-c(1.73,1.14)
MP<-c(1.75,1) 

#Export to tiff
tiff(filename = "figures_tables/Fig3_RightPanel_Timely.tif",
     width = width, 
     height =height,
     res=res,
     units = "px", 
     pointsize=9,
     bg = "white", 
     type = 'cairo')

par(mar=c(4,6,3,4)+0.1,lwd=lwd_border)

barplot(rbind(LC3, LC5, MP), width=0.2, xlim=c(0,2), ylim=c(0,4),beside=T,
        col=color,,space=c(0.5,0,0,0.5,0,0))
        
abline(h=seq(0,4,1),col=color_grid,lwd=lwd_grid)
abline(h=0)
abline(h=4)

mtext(c('Completed on Time', 'Not Completed on Time'),side=1,line=2,at=c(0.3,1)+0.1)

barplot(rbind(LC3, LC5, MP), width=0.2, xlim=c(0,2), ylim=c(0,4),beside=T,
        col=color,lwd=lwd_border,space=c(0.5,0,0,0.5,0,0),
        ylab='Average number of ways involved',add=T)


legend(0.05,4,
       legend=c('LC3 chairperson','LC5 councillor', 'MP'),
       fill=c('gray80','gray45','gray15'),
       bty='n'
)

dev.off()